package cn.itsource.controller.app;

import cn.dev33.satoken.annotation.SaIgnore;
import cn.itsource.pojo.ro.DriverOnLineRo;
import cn.itsource.pojo.ro.GeoRo;
import cn.itsource.pojo.ro.WxRegisterRo;
import cn.itsource.result.JSONResult;
import cn.itsource.service.IDriverService;
import feign.Param;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.validation.Valid;

@Tag(name = "司机对象",description = "司机对象")
@RestController
@RequestMapping("/app/driver")
public class AppDriverController {

    @Autowired
    public IDriverService driverService;

    @Operation(summary = "注册Driver", description = "基础对象注册接口")
    @Parameter(name = "driver", description = "注册的对象", required = true)
    @PostMapping("/registerDriver")
    @SaIgnore
    public JSONResult registerDriver(@RequestBody @Valid WxRegisterRo registerRo) {
        return driverService.registerDriver(registerRo);
    }
    @PostMapping("/onLine")
    @Parameter(name = "driverOnlineRo",description = "上线参数")
    public JSONResult online(@RequestBody @Valid DriverOnLineRo driverOnLineRo){
        return JSONResult.success(driverService.online(driverOnLineRo));
    }
    @GetMapping("/offLine")
    public JSONResult offLine(){
        driverService.offLine();
        return JSONResult.success();
    }

    @PostMapping("/geo")
    public JSONResult geo(@RequestBody @Valid GeoRo geoRo){
        driverService.geo(geoRo);
        return JSONResult.success();
    }

    @GetMapping("/pullDriverOrder")
    public JSONResult pullDriverOrder(){
        return JSONResult.success(driverService.pullDriverOrder());
    }
}
